package com.yisoo.rs.rsmovie.controller;

import java.util.Arrays;
import java.util.Map;

import com.yisoo.rs.common.utils.PageUtils;
import com.yisoo.rs.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.yisoo.rs.rsmovie.entity.DirectorEntity;
import com.yisoo.rs.rsmovie.service.DirectorService;



/**
 * 
 *
 * @author mmciel
 * @email 761998179@qq.com
 * @date 2021-12-03 17:03:59
 */
@RestController
@RequestMapping("rsmovie/director")
public class DirectorController {
    @Autowired
    private DirectorService directorService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = directorService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{directorId}")
    public R info(@PathVariable("directorId") Long directorId){
		DirectorEntity director = directorService.getById(directorId);

        return R.ok().put("director", director);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody DirectorEntity director){
		directorService.save(director);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody DirectorEntity director){
		directorService.updateById(director);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] directorIds){
		directorService.removeByIds(Arrays.asList(directorIds));

        return R.ok();
    }

}
